﻿using B.S.BasicData.Domain;
using B.S.BasicData.ErrorCode;
using B.S.BasicData.Read.Apilication.Common.Menu;
using B.S.BasicData.Read.DTOS;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class MenuController : ControllerBase
    {
        private readonly IMediator mediator;

        public MenuController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 菜单分页显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaimg<MenuDTO>> GetmenuHandle([FromQuery]GetmenuCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 父级菜单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<MenuNameDTO>>> GetmenunameHandle([FromQuery]GetmenunameCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 查询是否存在子集
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<menuModel>>> GetmenuParmentHandle([FromQuery]GetmenuParmentCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 菜单树形
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<TreeMenuDTO>>> TreeMenuHandle([FromQuery]TreeMenuCommon request)
        {
            return mediator.Send(request);
        }

        }
}
